package com.estar.assistsurvy.thread;

import com.estar.app.appsrvycabx.domain.DataVO;
import com.estar.assistsurvy.constant.Constants;
import com.socks.okhttp.plus.OkHttpProxy;
import com.socks.okhttp.plus.callback.OkCallback;
import com.socks.okhttp.plus.parser.OkXmlParser;

import android.os.Handler;
import android.os.Message;

public class VideoThread extends Thread {

	public DataVO dataVO;
	public Handler handler;
	public Message msg;
	
	public VideoThread(DataVO dataVO, Handler handler) {
		super();
		this.dataVO = dataVO;
		this.handler = handler;
		msg=handler.obtainMessage();
	}
	
	@Override
	public void run() {
		// TODO Auto-generated method stub
		OkHttpProxy.postData().url(Constants.VIDEO_SERVICE).setDataXml(dataVO).enqueue(new OkCallback<DataVO>(new OkXmlParser<DataVO>() {
        }) {


			@Override
			public void onSuccess(int code, DataVO dataVO) {
				// TODO Auto-generated method stub
//				if(dataVO.getResultCde().equals("1")){
//                    ReturnSubVideoSrvyVO returnSubVideoSrvyVO = (ReturnSubVideoSrvyVO)dataVO.getList().get(0);
                    msg.what=3;
//                    msg.obj=returnSubVideoSrvyVO;
                    msg.obj=dataVO;
                    msg.sendToTarget();
//				}
				
			}

			@Override
			public void onFailure(Throwable e) {
				// TODO Auto-generated method stub
				msg.what=4;
				msg.obj="视频连接失败，请稍后重试!";
				msg.sendToTarget();
			}

            
        });
	}
}
